﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace SharePointOptimizer.PL.WPF
{
    
    public class IssueInstance
    {
        public IssueInstance()
        {
            Databases = new ObservableCollection<IssueDatabase>();
            Categories = new ObservableCollection<IssueCategory>();
        }
       
       public  String Name { get; set; }
       public ObservableCollection<IssueDatabase> Databases { get; set; }
       public ObservableCollection<IssueCategory> Categories { get; set; }

        
       public int TotalNumberOfIssues()
       {
           int numberOfIssue = 0;


           foreach (var cat in Categories)
           {
               numberOfIssue += cat.Issues.Count;
           }

           foreach (var db in Databases)
           {
               numberOfIssue += db.TotalNumberOfIssues();
           }
           return numberOfIssue;

       }

       public override string ToString()
       {
           return "Instance: " + this.Name + " (" + TotalNumberOfIssues().ToString() + " issues)";
       }

    
    }
}
